<?php
my_component_load('xl_builder' , false);
my_component_load('testing' , false);
my_component_load('paging' , false);   
my_component_load('data_setting', false);
my_component_load('list_kalender' , false);   
my_component_load('pr_sisa_insentif' );
$task = isset($_GET['task']) ? $_GET['task'] : "";  
$sid = isset( $_GET['sid'] ) ? $_GET['sid']:  0;
$karyawan_id = isset( $_GET['karyawan_id'] ) ? $_GET['karyawan_id']:  0;

$modulname = "Penggajian _BN_ Sisa Insentif";
if($_SERVER['REQUEST_METHOD'] == "POST" ):
	switch($task){
		case "create_page":
			$validatepost = sisa_insentif_validate();
			if($validatepost){
				$errors = message_multi_error($validatepost);
				$content = $errors;
				$content .= form_sisa_insentif();
				generate_my_web($content,"","plain.php");
				exit; 
			}else {
				submit_sisa_insentif(); 
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}
			break; 	
	}
else: 
	if($task == "create"){ 
		$pagename = "Tambah Data";
		facebox_page('index.php?com=pr_sisa_insentif&task=create_page', $pagename , 260	);
	}elseif($task == "create_page"){
		ini_set("max_execution_time","10000");	
		$content = form_sisa_insentif();
		generate_my_web($content, '' ,"plain.php");
		exit;			
	}elseif($task == 'delete'){ 
		delete_sisa_insentif($sid);
		my_direct('index.php?com=pr_sisa_insentif');		
	}elseif($task =="list_karyawan"){
		load_facebox_script();
		$pagename = $modulname." _BN_ Karyawan";
		$view =  list_karyawan($sid);	
	}elseif($task =="list_bulan"){
		load_facebox_script();
		$pagename = $modulname." _BN_ Karyawan per Bulan";
		$view =  list_bulan($sid,$karyawan_id);	

	}elseif($task == "plaincetak_det"){
		@ob_end_clean(); 
		echo'<pre>';
		echo print_plain_det($sid);
		exit;
	}elseif($task == "excel_det"){
		header("Content-Type: application/xls");
		header("Content-Disposition: attachment;filename=sisa_insentif".rand().".xls");
		echo excel_report_det($sid);
		exit;								
	}else{
		$pagename = $modulname;
		load_facebox_script();
		$view =  list_sisa_insentif();
	}
	generate_my_web($view , $pagename );	
endif; 

